package management.procHistory.dataObjects
{
	import mx.collections.ArrayCollection;
	import common.utils.DateManager;
	[Bindable]
	public class ProcessHistoryDO
	{
		public var INTERNAL_ID:String = "0";
		public var WAREHOUSE:String = "";
		public var PROCESS_TYPE:String = "";
		public var CONDITION:String = "";
		public var IDENTIFIER1:String = "";
		public var IDENTIFIER2:String = "";
		public var IDENTIFIER3:String = "";
		public var IDENTIFIER4:String = "";
		public var MESSAGE:String = "";
		public var USER_STAMP:String = "";
		public var DATE_TIME_STAMP:String = DateManager.GetTodayString();

		
		public function ProcessHistoryDO()
		{
		}

		public function Init(xmlObj:XML):void{		
			if(null == xmlObj)
				return;
			else{
				for each (var itemProp:XML in xmlObj.children()) {
					//Use XML node name to reference matching property in value object				
					this[itemProp.name()] = itemProp;
				}
			}
		}
		
		public function ToXML():XML{
			var xmlObj:XML = 
				<PROCESS_HISTORY>
					<INTERNAL_ID>{INTERNAL_ID}</INTERNAL_ID>
					<WAREHOUSE>{WAREHOUSE}</WAREHOUSE>
					<PROCESS_TYPE>{PROCESS_TYPE}</PROCESS_TYPE>
					<CONDITION>{CONDITION}</CONDITION>
					<IDENTIFIER1>{IDENTIFIER1}</IDENTIFIER1>
					<IDENTIFIER2>{IDENTIFIER2}</IDENTIFIER2>
					<IDENTIFIER3>{IDENTIFIER3}</IDENTIFIER3>
					<IDENTIFIER4>{IDENTIFIER4}</IDENTIFIER4>
					<MESSAGE>{MESSAGE}</MESSAGE>
					<USER_STAMP>{USER_STAMP}</USER_STAMP>
					<DATE_TIME_STAMP>{DATE_TIME_STAMP}</DATE_TIME_STAMP>
				
				</PROCESS_HISTORY>;
			return xmlObj;
		}

		public static function getItems(list:XMLList):ArrayCollection
		{
			var ac:ArrayCollection = new ArrayCollection();
			for each(var xml:XML in list)
			{
				var attrDO:ProcessHistoryDO = new ProcessHistoryDO();
				attrDO.Init(xml);
				ac.addItem(attrDO);
			}
			return ac;
		}			
	}
}